﻿
using System;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EnterpriseServices.Service
{
    /// <summary>
    /// 
    /// </summary>
    public partial class PasswordProxy 
    {
        #region IPasswordManager Members

        /// <summary>
        /// Enables the password reset.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public bool EnablePasswordReset(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.EnablePasswordReset(application);
        }

        /// <summary>
        /// Enables the password retrieval.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public bool EnablePasswordRetrieval(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.EnablePasswordRetrieval(application);
        }

        /// <summary>
        /// Generates the password.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="length">The length.</param>
        /// <param name="numberOfNonAlphanumericCharacters">The number of non alphanumeric characters.</param>
        /// <returns></returns>
        public string GeneratePassword(string application, int length, int numberOfNonAlphanumericCharacters)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GeneratePassword(application, length, numberOfNonAlphanumericCharacters);
        }

        /// <summary>
        /// Gets the max invalid password attempts.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int GetMaxInvalidPasswordAttempts(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetMaxInvalidPasswordAttempts(application);
        }

        /// <summary>
        /// Gets the min required non alphanumeric characters.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int GetMinRequiredNonAlphanumericCharacters(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetMinRequiredNonAlphanumericCharacters(application);
        }

        /// <summary>
        /// Gets the length of the min required password.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int GetMinRequiredPasswordLength(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetMinRequiredPasswordLength(application);
        }

        /// <summary>
        /// Gets the password attempt window.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int GetPasswordAttemptWindow(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetPasswordAttemptWindow(application);
        }

        /// <summary>
        /// Gets the password strength regular expression.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public string GetPasswordStrengthRegularExpression(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetPasswordStrengthRegularExpression(application);
        }

        /// <summary>
        /// Requireses the question and answer.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public bool RequiresQuestionAndAnswer(string application)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.RequiresQuestionAndAnswer(application);
        }

        /// <summary>
        /// Resets the password.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        public string ResetPassword(string application, string userName)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.ResetPassword(application, userName);
        }

        /// <summary>
        /// Resets the password with question and answer.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <returns></returns>
        public string ResetPasswordWithQuestionAndAnswer(string application, string userName, string passwordAnswer)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.ResetPasswordWithQuestionAndAnswer(application, userName, passwordAnswer);
        }

        /// <summary>
        /// Gets the password.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <returns></returns>
        public string GetPassword(string application, string userName, string passwordAnswer)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetPassword(application, userName, passwordAnswer);
        }

        /// <summary>
        /// Gets the password question.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        public string GetPasswordQuestion(string application, string userName)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            return proxy.GetPasswordQuestion(application, userName);
        }

        /// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="newPassword">The new password.</param>
        public void ChangePassword(string application, string userName, string newPassword)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            proxy.ChangePassword(application, userName, newPassword);
        }

        /// <summary>
        /// Changes the password with answer.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <param name="newPassword">The new password.</param>
        public void ChangePasswordWithAnswer(string application, string userName, string passwordAnswer, string newPassword)
        {
            IPasswordManager proxy = new ChannelFactory<IPasswordManager>().CreateChannel();
            proxy.ChangePasswordWithAnswer(application, userName, passwordAnswer, newPassword);
        }

        #endregion
    }
}
